package com.pansoft.openplanet.adapter;

import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import com.pansoft.openplanet.fragment.RestoreByMnemonicFragment;
import com.pansoft.openplanet.fragment.RestoreByPrivateKeyFragment;

/**
 * Created by will on 18-3-27.
 */

public class RestorePagerAdapter extends FragmentPagerAdapter {

    private String[] titles;

    public RestorePagerAdapter(FragmentManager fm, String[] titles) {
        super(fm);
        this.titles = titles;
    }

    @Override
    public Fragment getItem(int position) {
        if (position == 0) {
            RestoreByMnemonicFragment restoreByMnemonicFragment = new RestoreByMnemonicFragment();
            Bundle bundle = new Bundle();
            bundle.putString("status", "all");
            restoreByMnemonicFragment.setArguments(bundle);
            return restoreByMnemonicFragment;
        }else {
            RestoreByPrivateKeyFragment restoreByPrivateKeyFragment = new RestoreByPrivateKeyFragment();
            Bundle bundle = new Bundle();
            bundle.putString("status", "0");
            restoreByPrivateKeyFragment.setArguments(bundle);
            return restoreByPrivateKeyFragment;
        }

    }

    @Override
    public int getCount() {
        return titles.length;
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return titles[position];
    }
}
